package com.epfresh.supplier.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.epfresh.api.utils.MarketPermissionUtil;
import com.epfresh.supplier.Listener.IndexIconOnClickListener;
import com.epfresh.supplier.R;
import com.epfresh.supplier.entity.HomePart;
import com.epfresh.supplier.widget.CommonRecyclerAdapter;
import com.epfresh.supplier.widget.ViewHolder;

import java.util.List;

public class HomePart2Adapter extends CommonRecyclerAdapter<HomePart> {
    private IndexIconOnClickListener indexIconOnClickListener;

    public HomePart2Adapter(Context context, List<HomePart> datas) {
        super(context, datas, R.layout.home_part);
    }

    public void setDatas(List<HomePart> datas) {
        super.setData(datas);
    }

    public void setListener(IndexIconOnClickListener indexIconOnClickListener) {
        this.indexIconOnClickListener = indexIconOnClickListener;
    }

    @Override
    public void convert(ViewHolder holder, final HomePart item, int position) {
        ImageView pic = holder.getView(R.id.iv_pic);
        RelativeLayout rlIcon = holder.getView(R.id.rl_icon);
        switch (item.getName()) {
            case MarketPermissionUtil.appSupplierOrder:
                pic.setBackgroundResource(R.mipmap.order);
                holder.setText(R.id.tv_name, "销售订单");
                break;
            case MarketPermissionUtil.appSupplierProductSelling:
                pic.setBackgroundResource(R.mipmap.spot_commodity);
                holder.setText(R.id.tv_name, "现货商品");
                break;
            case MarketPermissionUtil.appSupplierIncome:
                pic.setBackgroundResource(R.mipmap.my_income);
                holder.setText(R.id.tv_name, "我的收入");
                break;
            case MarketPermissionUtil.appSupplierProductStanding_book:
                pic.setBackgroundResource(R.mipmap.my_ledger);
                holder.setText(R.id.tv_name, "我的台账");
                break;
            case MarketPermissionUtil.appSupplierOrderJmt:
                pic.setBackgroundResource(R.mipmap.waiver);
                holder.setText(R.id.tv_name, "减免退");
                break;
            case MarketPermissionUtil.appSupplierEmployee:
                pic.setBackgroundResource(R.mipmap.staff_management);
                holder.setText(R.id.tv_name, "员工管理");
                break;
            case MarketPermissionUtil.appSupplierProductPurchase:
                pic.setBackgroundResource(R.mipmap.stock_management);
                holder.setText(R.id.tv_name, "进货管理");
                break;
            case MarketPermissionUtil.appSupplierCustomer:
                pic.setBackgroundResource(R.mipmap.customer_management);
                holder.setText(R.id.tv_name, "客户管理");
                break;
            case MarketPermissionUtil.appSupplierProductPrice:
                pic.setBackgroundResource(R.mipmap.changemoney);
                holder.setText(R.id.tv_name, "变价");
                break;
            case MarketPermissionUtil.appSupplierToIncome:
                pic.setBackgroundResource(R.mipmap.collection);
                holder.setText(R.id.tv_name, "收款");
                break;
        }
        rlIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (indexIconOnClickListener != null)
                    indexIconOnClickListener.onclick(item.getName());
            }
        });
    }

}
